home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel PPC / lib_std / character_ref.e < prev    next >
Encoding:
Text File  |  1996-06-13  |  1.3 KB  |  71 lines  |  [TEXT/EDIT]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class CHARACTER_REF
  5.  
  6. inherit
  7.    COMPARABLE 
  8.       redefine infix "<", compare, fill_tagged_out_memory
  9.       end;
  10.    
  11. creation make
  12.  
  13. feature 
  14.    
  15.    item: CHARACTER;
  16.  
  17.    make(value: CHARACTER) is
  18.       do
  19.      item := value;
  20.       end;
  21.     
  22. feature
  23.    
  24.    set_item(value: like item) is
  25.       do
  26.      item := value;
  27.       end;
  28.  
  29.    infix "<" (other: like Current): BOOLEAN is
  30.      -- Is Current less than `other'?
  31.       do
  32.      Result := item < other.item
  33.       end;
  34.  
  35.    compare (other: like Current) : INTEGER is
  36.      -- Compare Current with `other'.
  37.      -- '<' <==> Result < 0
  38.      -- '>' <==> Result > 0
  39.      -- Otherwise Result = 0
  40.       do
  41.      Result := code - other.code
  42.       end;
  43.  
  44.    code: INTEGER is
  45.      -- ASCII code of Current
  46.       do
  47.      Result := item.code
  48.       end;
  49.    
  50.    to_upper: like Current is
  51.      -- Conversion of Current to upper case
  52.       do
  53.      !!Result.make (item.to_upper)
  54.       end;
  55.  
  56.    to_lower: like Current is
  57.      -- Conversion of Current to lower case
  58.       do
  59.      !!Result.make (item.to_lower)
  60.       end;
  61.  
  62. feature -- Object Printing :
  63.  
  64.    fill_tagged_out_memory is
  65.       do
  66.      tagged_out_memory.append("item: "); 
  67.      item.fill_tagged_out_memory;
  68.       end;
  69.  
  70. end -- CHARACTER_REF
  71.